import request, { get, postForm } from '@/utils/request'

export function generator(tableName) {
  return postForm('/gen/code/opt/genrator', { tableName: tableName })
}

export function save(data) {
  return postForm('/gen/code/opt/config/save', { columnInfos: JSON.stringify(data) })
}

export function sync(tables) {
  return postForm('/gen/code/opt/sync', { tableNames: JSON.stringify(tables) })
}

export function download(tableName) {
  return request({
    url: '/gen/code/opt/download',
    method: 'get',
    params: { tableName: tableName },
    responseType: 'blob'
  })
}

export function preview(tableName) {
  return get('/gen/code/opt/preview', { tableName: tableName })
}

